home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / meteor.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  9KB  |  314 lines

  1. /***************************************************************************
  2.  
  3. Meteoroids Memory Map
  4.  
  5. driver by Zsolt Vasvari
  6.  
  7.  
  8. 0000-3fff   R    ROM
  9. 4000-43ff    R/W    RAM
  10. 7000-7002    R   input ports 0-2
  11. 7000-700f      W most of the locations are unknown, but
  12. 7000          W sound command
  13. 7001          W sound CPU IRQ trigger on bit 3 falling edge
  14. 700e          W main CPU interrupt enable (it uses RST7.5)
  15. 8000-83ff   R/W bit 0-7 of character code
  16. 9000-93ff   R/W attributes RAM
  17.                 bit 0   -  bit 8 of character code
  18.                 bit 1-3 -  unused
  19.                 bit 4-6 -  color
  20.                 bit 7   -  unused
  21. a000-a3ff    R/W X/Y scroll position of each character (can be scrolled up
  22.                 to 7 pixels in each direction)
  23.  
  24.  
  25. ***************************************************************************/
  26.  
  27. #include "driver.h"
  28. #include "vidhrdw/generic.h"
  29. #include "cpu/i8085/i8085.h"
  30. #include "cpu/i8039/i8039.h"
  31.  
  32.  
  33. extern unsigned char *meteor_scrollram;
  34.  
  35. void meteor_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  36.  
  37.  
  38. static int meteor_interrupt(void)
  39. {
  40.     return I8085_RST75;
  41. }
  42.  
  43.  
  44. static int meteor_SN76496_latch;
  45. static int meteor_SN76496_select;
  46.  
  47. static WRITE_HANDLER( meteor_SN76496_latch_w )
  48. {
  49.     meteor_SN76496_latch = data;
  50. }
  51.  
  52. static READ_HANDLER( meteor_SN76496_select_r )
  53. {
  54.     return meteor_SN76496_select;
  55. }
  56.  
  57. static WRITE_HANDLER( meteor_SN76496_select_w )
  58. {
  59.     meteor_SN76496_select = data;
  60.  
  61.     if (~data & 0x40)  SN76496_0_w(0, meteor_SN76496_latch);
  62.     if (~data & 0x20)  SN76496_1_w(0, meteor_SN76496_latch);
  63.     if (~data & 0x10)  SN76496_2_w(0, meteor_SN76496_latch);
  64. }
  65.  
  66. static READ_HANDLER( meteor_t0_r )
  67. {
  68.     /* SN76496 status according to Al - not supported by MAME?? */
  69.     return rand() & 1;
  70. }
  71.  
  72.  
  73. static int meteor_soundtrigger;
  74.  
  75. static WRITE_HANDLER( meteor_soundtrigger_w )
  76. {
  77.     if ((meteor_soundtrigger & 0x08) && (~data & 0x08))
  78.     {
  79.         cpu_cause_interrupt(1, I8039_EXT_INT);
  80.     }
  81.  
  82.     meteor_soundtrigger = data;
  83. }
  84.  
  85.  
  86. static struct MemoryReadAddress readmem[] =
  87. {
  88.     { 0x0000, 0x3fff, MRA_ROM },
  89.     { 0x4000, 0x43ff, MRA_RAM },
  90.     { 0x7000, 0x7000, input_port_0_r },
  91.     { 0x7001, 0x7001, input_port_1_r },
  92.     { 0x7002, 0x7002, input_port_2_r },
  93.     { 0x8000, 0x83ff, MRA_RAM },
  94.     { 0x9000, 0x93ff, MRA_RAM },
  95.     { 0xa000, 0xa3ff, MRA_RAM },
  96.     { -1 }  /* end of table */
  97. };
  98.  
  99. static struct MemoryWriteAddress writemem[] =
  100. {
  101.     { 0x0000, 0x3fff, MWA_ROM },
  102.     { 0x4000, 0x43ff, MWA_RAM },
  103.     { 0x7000, 0x7000, soundlatch_w },
  104.     { 0x7001, 0x7001, meteor_soundtrigger_w },
  105.     { 0x700e, 0x700e, interrupt_enable_w },
  106.     { 0x700f, 0x700f, MWA_NOP },
  107.     { 0x8000, 0x83ff, MWA_RAM, &videoram, &videoram_size },
  108.     { 0x9000, 0x93ff, MWA_RAM, &colorram },
  109.     { 0xa000, 0xa3ff, MWA_RAM, &meteor_scrollram },
  110.     { -1 }  /* end of table */
  111. };
  112.  
  113. static struct MemoryReadAddress sound_readmem[] =
  114. {
  115.     { 0x0000, 0x07ff, MRA_ROM },
  116.     { -1 }    /* end of table */
  117. };
  118.  
  119. static struct MemoryWriteAddress sound_writemem[] =
  120. {
  121.     { 0x0000, 0x07ff, MWA_ROM },
  122.     { -1 }    /* end of table */
  123. };
  124.  
  125. static struct IOReadPort sound_readport[] =
  126. {
  127.     { I8039_bus, I8039_bus, soundlatch_r },
  128.     { I8039_p2,  I8039_p2,  meteor_SN76496_select_r },
  129.     { I8039_t0,  I8039_t0,  meteor_t0_r },
  130.     { -1 }    /* end of table */
  131. };
  132.  
  133. static struct IOWritePort sound_writeport[] =
  134. {
  135.     { I8039_p1,  I8039_p1, meteor_SN76496_latch_w },
  136.     { I8039_p2,  I8039_p2, meteor_SN76496_select_w },
  137.     { -1 }    /* end of table */
  138. };
  139.  
  140.  
  141. INPUT_PORTS_START( meteor )
  142.     PORT_START      /* DSW */
  143.     PORT_DIPNAME( 0x03, 0x02, DEF_STR( Coin_A ) )
  144.     PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
  145.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_1C ) )
  146.     PORT_DIPSETTING(    0x01, DEF_STR( 1C_2C ) )
  147.     PORT_DIPSETTING(    0x03, DEF_STR( Free_Play ) )
  148.     PORT_DIPNAME( 0x04, 0x00, DEF_STR( Coin_B ) )
  149.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_3C ) )
  150.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_6C ) )
  151.     PORT_DIPNAME( 0x18, 0x08, DEF_STR( Lives ) )
  152.     PORT_DIPSETTING(    0x00, "2" )
  153.     PORT_DIPSETTING(    0x08, "3" )
  154.     PORT_DIPSETTING(    0x10, "4" )
  155.     PORT_DIPSETTING(    0x18, "5" )
  156.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Bonus_Life ) )
  157.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  158.     PORT_DIPSETTING(    0x20, DEF_STR( On ) )
  159.     PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )    /* probably unused */
  160.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  161.     PORT_DIPSETTING(    0x40, DEF_STR( On ) )
  162.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )  /* probably unused */
  163.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  164.     PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  165.  
  166.     PORT_START      /* IN0 */
  167.     PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_2WAY )
  168.     PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )
  169.     PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
  170.     PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_COIN2 )
  171.     PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 )
  172.     PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_START2 )
  173.     PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_START1 )
  174.     PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_2WAY )
  175.  
  176.     PORT_START      /* IN1 */
  177.     PORT_BITX( 0x08, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
  178.     PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_VBLANK )
  179. INPUT_PORTS_END
  180.  
  181.  
  182. static struct GfxLayout charlayout =
  183. {
  184.     8,8,    /* 8*8 chars */
  185.     512,    /* 512 characters */
  186.     3,      /* 3 bits per pixel */
  187.     { 2*512*8*8, 512*8*8, 0 },  /* The bitplanes are seperate */
  188.     { 0, 1, 2, 3, 4, 5, 6, 7},
  189.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8},
  190.     8*8     /* every char takes 8 consecutive bytes */
  191. };
  192.  
  193.  
  194. static struct GfxDecodeInfo gfxdecodeinfo[] =
  195. {
  196.     { REGION_GFX1, 0, &charlayout,   0, 8 },
  197.     { -1 } /* end of array */
  198. };
  199.  
  200.  
  201. /* 1-bit RGB palette */
  202. static unsigned char palette[] =
  203. {
  204.     0x00, 0x00, 0x00,
  205.     0xff, 0x00, 0x00,
  206.     0x00, 0xff, 0x00,
  207.     0xff, 0xff, 0x00,
  208.     0x00, 0x00, 0xff,
  209.     0xff, 0x00, 0xff,
  210.     0x00, 0xff, 0xff,
  211.     0xff, 0xff, 0xff
  212. };
  213. static unsigned short colortable[] =
  214. {
  215.     0, 1, 2, 3, 4, 5, 6, 7,
  216.     0, 2, 3, 4, 5, 6, 7, 0,     /* not sure about these, but they are only used */
  217.     0, 3, 4, 5, 6, 7, 0, 1,  /* to change the text color. During the game,   */
  218.     0, 4, 5, 6, 7, 0, 1, 2,  /* only color 0 is used, which is correct.      */
  219.     0, 5, 6, 7, 0, 1, 2, 3,
  220.     0, 6, 7, 0, 1, 2, 3, 4,
  221.     0, 7, 0, 1, 2, 3, 4, 5,
  222.     0, 0, 1, 2, 3, 4, 5, 6,
  223. };
  224. static void init_palette(unsigned char *game_palette, unsigned short *game_colortable,const unsigned char *color_prom)
  225. {
  226.     memcpy(game_palette,palette,sizeof(palette));
  227.     memcpy(game_colortable,colortable,sizeof(colortable));
  228. }
  229.  
  230.  
  231. static struct SN76496interface sn76496_interface =
  232. {
  233.     3,        /* 3 chips */
  234.     { 2000000, 2000000, 2000000 },    /* 8 MHz / 4 ?*/
  235.     { 100, 100, 100 }
  236. };
  237.  
  238.  
  239. static struct MachineDriver machine_driver_meteor =
  240. {
  241.     /* basic machine hardware */
  242.     {
  243.         {
  244.             CPU_8085A,
  245.             4000000,        /* 4.00 MHz??? */
  246.             readmem,writemem,0,0,
  247.             meteor_interrupt,1
  248.         },
  249.         {
  250.             CPU_I8035 | CPU_AUDIO_CPU,
  251.             6144000/8,        /* divisor ??? */
  252.             sound_readmem,sound_writemem,sound_readport,sound_writeport,
  253.             ignore_interrupt,0  /* IRQ's are triggered by the main CPU */
  254.         }
  255.     },
  256.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,  /* frames per second, vblank duration */
  257.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  258.     0,
  259.  
  260.     /* video hardware */
  261.     32*8, 32*8, { 0*8, 32*8-1, 0*8, 28*8-1 },
  262.     gfxdecodeinfo,
  263.     sizeof(palette) / sizeof(palette[0]) / 3, sizeof(colortable) / sizeof(colortable[0]),
  264.     init_palette,
  265.  
  266.     VIDEO_TYPE_RASTER,
  267.     0,
  268.     generic_bitmapped_vh_start,
  269.     generic_bitmapped_vh_stop,
  270.     meteor_vh_screenrefresh,
  271.  
  272.     /* sound hardware */
  273.     0,0,0,0,
  274.     {
  275.         {
  276.             SOUND_SN76496,
  277.             &sn76496_interface
  278.         }
  279.     }
  280. };
  281.  
  282.  
  283. /***************************************************************************
  284.  
  285.   Game driver(s)
  286.  
  287. ***************************************************************************/
  288. ROM_START( meteor )
  289.     ROM_REGION( 0x10000, REGION_CPU1 )       /* 64k for code */
  290.     ROM_LOAD( "vm1",           0x0000, 0x0800, 0x894fe9b1 )
  291.     ROM_LOAD( "vm2",           0x0800, 0x0800, 0x28685a68 )
  292.     ROM_LOAD( "vm3",           0x1000, 0x0800, 0xc88fb12a )
  293.     ROM_LOAD( "vm4",           0x1800, 0x0800, 0xc5b073b9 )
  294.                             /*0x2000- 0x27ff empty */
  295.     ROM_LOAD( "vm6",           0x2800, 0x0800, 0x9969ec43 )
  296.     ROM_LOAD( "vm7",           0x3000, 0x0800, 0x39f43ac2 )
  297.     ROM_LOAD( "vm8",           0x3800, 0x0800, 0xa0508de3 )
  298.  
  299.     ROM_REGION( 0x1000, REGION_CPU2 )        /* sound MCU */
  300.     ROM_LOAD( "vm5",           0x0000, 0x0800, 0xb14ccd57 )
  301.  
  302.     ROM_REGION( 0x3000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  303.     ROM_LOAD( "rm1v",         0x0000, 0x0800, 0xd621fe96 )
  304.     ROM_LOAD( "rm2v",         0x0800, 0x0800, 0xb3981251 )
  305.     ROM_LOAD( "gm1v",         0x1000, 0x0800, 0xd44617e8 )
  306.     ROM_LOAD( "gm2v",         0x1800, 0x0800, 0x0997d945 )
  307.     ROM_LOAD( "bm1v",         0x2000, 0x0800, 0xcc97c890 )
  308.     ROM_LOAD( "bm2v",         0x2800, 0x0800, 0x2858cf5c )
  309. ROM_END
  310.  
  311.  
  312.  
  313. GAME( 1981, meteor, 0, meteor, meteor, 0, ROT270, "Venture Line", "Meteoroids" )
  314.